Method and apparatus for changing background color of toolbar with dominant color of picture

ABSTRACT

A computer-based method includes transparentizing a background color of a toolbar of a currently running application, extracting a dominant color of a picture currently displayed on a user interface of the application, and displaying the toolbar using a color based on the extracted dominant color as the background color of the toolbar, along with the picture on the user interface of the application, and when the displayed picture is moved up and down or left and right with a user operation, keeping the background color of the toolbar unchanged from the color based on the extracted dominant color when the displayed picture is not completely moved out of an operation interface, and recovering the background color of the toolbar to a default color when the displayed picture is completely moved out of the operation interface and the operation interface does not have a picture or a color to display.

CROSS REFERENCE TO RELATED APPLICATION

This application claims the priority of Chinese Patent Application No.201610562451.3 filed in the State Intellectual Property Office of thePeople's Republic of China on Jul. 14, 2016, the content of which isincorporated herein by reference in its entirety.

TECHNICAL FIELD

The present invention relates to the field of web page technologies, andin particular, to a method and an apparatus for changing a backgroundcolor of a toolbar with a dominant color of a picture.

RELATED ART

With rapid development of intelligent terminals, various third-partyapplications (APPs) applied to the intelligent terminals are developed.A picture is displayed when an existing APP displays an interface on anintelligent terminal, especially when displaying a web page by a browserat a client site. Moreover, an APP usually has a toolbar to facilitate auser to implement various operations on the APP.

Currently, in the prior art, when various APPs are being developed, atechnical solution of a fixed toolbar is used, and a color of thetoolbar is also fixed. However, when an existing APP displays a bigpicture (that is, the picture occupies a full screen or almost occupiesa full screen), or after a user changes a background color of an APPinterface, since a background color of a toolbar of the APP is fixed,the harmony and correlation of interface display are affected.Consequently, the overall look of the display interface is relativelyrigid, it feels like that the display interface is cut apart, and userexperiences are poor.

SUMMARY

An objective of the present invention is to provide a method and anapparatus for changing a background color of a toolbar with a dominantcolor of a picture, so as to resolve the foregoing problem.

According to a first aspect of the present invention, an embodiment ofthe present invention provides a method for changing a background colorof a toolbar with a dominant color of a picture, including:

transparentizing a background color of a toolbar of a currently runningapplication;

extracting a dominant color of a picture currently displayed on a userinterface of the application; and

using the extracted color as the background color of the toolbar, anddisplaying the extracted color.

Preferably, the method further includes: automatically changing a buttoncolor of the toolbar according to the changed background color of thetoolbar.

Preferably, the button color of the toolbar is automatically changed byusing a color-to-grayscale method, where the color-to-grayscale methodincludes:

using a formula Gray=R*0.299+G*0.587+B*0.114, where Gray is a grayscalevalue, R is a red color value of the extracted dominant color of thepicture, G is a green color value of the extracted dominant color of thepicture, and B is a blue color value of the extracted dominant color ofthe picture; and converting the RGB color values of the extracteddominant color of the picture to a grayscale value, where when thegrayscale value ranges from 0 to 0.5, the button color of the toolbar ischanged to black, and when the grayscale value ranges from 0.5 to 1, thebutton color of the toolbar is changed to white.

Preferably, the method further includes: when the displayed picture ismoved up and down or left and right with a user operation, keeping thebackground color of the toolbar unchanged when the displayed picture isnot completely moved out of an operation interface; and recovering thebackground color of the toolbar to a default color when the displayedpicture is completely moved out of the operation interface and theoperation interface does not have a picture or a color to display.

Preferably, the step of extracting a dominant color of a currentlydisplayed picture includes:

a picture obtaining step for obtaining the currently displayed picture,where the picture includes multiple display units;

a color classification step for performing, in a first color space,classification processing on each display unit included in the pictureso as to obtain several color categories by classifying display unitshaving same color characteristics into a same color category, andcalculating a quantity of display units corresponding to each colorcategory;

a color-weight calculation step for converting each color category fromthe first color space to a second color space, obtaining a value of eachcolor category in each dimension of the second color space, determininga weighting function of each dimension of the second color spaceaccording to a factor that is in a display requirement and thatcorresponds to each dimension of the second color space, and calculatinga weight of each color category according to the value of each colorcategory in each dimension of the second color space and the weightingfunction of each dimension; and

a dominant-color extraction step for calculating color values accordingto the quantity of display units corresponding to each color categoryand the weight of the color category, and extracting a color categoryhaving a highest color value to serve as the dominant color of thepicture.

Preferably, the color-weight calculation step includes:

converting N color categories obtained after classification from thefirst color space to the second color space having M dimensions toobtain a value of each color category in the second color space, where avalue of an i^(th) color category in a j^(th) dimension of the secondcolor space is P_(ij)(i=1, . . . , N; j=1, . . . , M;

configuring the weighting function of each dimension of the second colorspace according to the factor that is in the display requirement andthat corresponds to each dimension of the second color space, where aweighting function of the j^(th) dimension is F(x_(j))(j=1, . . . , N);and

calculating the weight of each color category according to the value andthe weighting function of each color category in the second color space,where a weight W_(i) of the i^(th) category of color is

${W_{i} = {{\sum\limits_{j = 1}^{M}{F\left( P_{ij} \right)}} + C}},$where C is a constant except 0.

Preferably, the weighting function is set so that a dimension with ahigher correlation with a factor in the display requirement, associateswith a larger result value calculated by the weighting function of thedimension.

Preferably, the first color space is an RGB space, and the second colorspace is an HSV space.

Preferably, in the color-weight calculation step, when a factorcorresponding to a saturation rate of the HSV space in the displayrequirement is making a displayed color brighter, a weighting functionof the saturation rate is set to F(S)=(S/2^(A))²,

where S is a value of the saturation rate, and A is a positive integer.

Preferably, in the color-weight calculation step, when a factorcorresponding to lightness of the HSV space in the display requirementis avoiding an extreme color unfavorable to text display, a weightingfunction of the lightness is set to:

${F(V)} = \left\{ {\begin{matrix}V & {V < 2^{{p\; 2} - 1}} \\2^{{p\; 2} - 1} & {2^{{p\; 2} - 1} \leq V \leq {2^{{p\; 2} - 2} \times 3}} \\{2^{{p\; 2} + 1} - {2 \times V}} & {V > 2^{{p\; 2} - 1}}\end{matrix},} \right.$

where V is a value of the lightness, and a value of p2 is obtainedaccording to a maximum value 2^(p2)−1 of the value V of the lightness ofthe HSV space.

Preferably, the color classification step further includes: performing,by using the following formula, downsampling on the display unitsincluded in the picture:

${\left\lbrack {S_{1}^{\prime},S_{2}^{\prime},{\ldots\mspace{14mu} S_{T}^{\prime}}} \right\rbrack = \left\lbrack {\left\lfloor \frac{S_{1}}{2^{q\; 1}} \right\rfloor,\left\lfloor \frac{S_{2}}{2^{q\; 1}} \right\rfloor,\ldots\mspace{14mu},\left\lfloor \frac{S_{T}}{2^{q\; 1}} \right\rfloor} \right\rbrack},$and classifying display units that are obtained after downsampling andthat have same [S₁′, S₂′, . . . S_(T)′] into a same color category,

where T is a quantity of dimensions of the first color space [S₁, . . ., S_(T)] is a value of a single display unit in the first color space,q1 is an integer greater than 0 and less than p, and a value of p isobtained according to a known maximum value 2^(p)−1 of each dimension inthe first color space.

Preferably, in the dominant-color extraction step, a color value of eachcolor category is obtained by multiplying the quantity of display unitscorresponding to each color category by the weight.

Preferably, the dominant-color extraction step includes: extracting anintermediate color value of a color category that has a largest colorvalue to serve as the dominant color of the picture.

Preferably, before the color classification step, the method furtherincludes: a step of scaling down the picture, in order to reduce sidepixels of the picture to a proper value.

Preferably, the method further includes: a step of matching a templateto determine a final dominant color for matching the extracted dominantcolor of the picture with a pre-configured template color, and selectinga template color nearest to the dominant color of the picture as thefinal dominant color of the picture.

According to a second aspect of the present invention, an embodiment ofthe present invention provides an apparatus for changing a backgroundcolor of a toolbar with a dominant color of a picture, including:

a module for transparentizing a background color of a toolbar,configured to transparentize a background color of a toolbar of acurrently running application;

a module for extracting a dominant color of a picture, configured toextract a dominant color of a picture currently displayed on a userinterface of the application; and

a module for changing a background color of a toolbar, configured to:use the extracted color as the background color of the toolbar, anddisplay the extracted color.

Preferably, the apparatus further includes: a module for changing abutton color of a toolbar, configured to automatically change a buttoncolor of the toolbar according to the changed background color of thetoolbar.

Preferably, the button color of the toolbar is automatically changed byusing a color-to-grayscale method, where the color-to-grayscale methodincludes:

using a formula Gray=R*0.299+G*0.587+B*0.114, where Gray is a grayscalevalue, R is a red color value of the extracted dominant color of thepicture, G is a green color value of the extracted dominant color of thepicture, and B is a blue color value of the extracted dominant color ofthe picture; and converting the RGB color values of the extracteddominant color of the picture to a grayscale value, where when thegrayscale value ranges from 0 to 0.5, the button color of the toolbar ischanged to black, and when the grayscale value ranges from 0.5 to 1, thebutton color of the toolbar is changed to white.

Preferably, the apparatus further includes: a module for recovering abackground color of a toolbar, configured to recover the backgroundcolor of the toolbar to a default color when the displayed picture iscompletely moved out of an operation interface and the operationinterface does not have a picture or a color to display.

Preferably, the module for extracting a dominant color of a pictureincludes:

a picture obtaining module, configured to obtain the currently displayedpicture, where the picture includes multiple display units;

a color classification module, configured to: perform, in a first colorspace, classification processing on each display unit included in thepicture so as to obtain several color categories by classifying displayunits having same color characteristics into a same color category, andcalculate a quantity of display units corresponding to each colorcategory;

a color-weight calculation module, configured to: convert each colorcategory from the first color space to a second color space, obtain avalue of each color category in each dimension of the second colorspace, determine a weighting function of each dimension of the secondcolor space according to a factor that is in a display requirement andthat corresponds to each dimension of the second color space, andcalculate a weight of each color category according to the value of eachcolor category in each dimension of the second color space and theweighting function of each dimension; and

a dominant-color extraction module, configured to: calculate colorvalues according to the quantity of display units corresponding to eachcolor category and the weight of the color category, and extract a colorcategory having a highest color value to serve as the dominant color ofthe picture.

Preferably, the color-weight calculation module is configured to:

convert N color categories obtained after classification from the firstcolor space to the second color space having M dimensions to obtain avalue of each color category in the second color space, where a value ofan i^(th) color category in a j^(th) dimension of the second color spaceis P_(ij)(i=1, . . . ; j=1, . . . , M);

set the weighting function of each dimension of the second color spaceaccording to the factor that is in the display requirement and thatcorresponds to each dimension of the second color space, where aweighting function of the j^(th) dimension is F(x_(j))(j=1 . . . , N);and

calculate the weight of each color category according to the value andthe weighting function of each color category in the second color space,where a weight i of the W_(i) _(th) category of color is

${W_{i} = {{\sum\limits_{j = 1}^{M}{F\left( P_{ij} \right)}} + C}},$where C is a constant except 0.

Preferably, the color-weight calculation module is configured to set theweighting function so that a dimension having a higher correlation witha factor in the display requirement indicates a larger result valuecalculated by the weighting function of the dimension.

Preferably, the first color space is an RGB space, and the second colorspace is an HSV space.

Preferably, the color-weight calculation module is configured to: when afactor corresponding to a saturation rate of the HSV space in thedisplay requirement is making a displayed color brighter, set aweighting function of the saturation rate to F(S)=(S/2^(A))²,

where S is a value of the saturation rate, and A is a positive integer.

Preferably, the color-weight calculation module is configured to: when afactor corresponding to lightness of the HSV space in the displayrequirement is avoiding an extreme color unfavorable to text display,set a weighting function of the lightness to:

${F(V)} = \left\{ {\begin{matrix}V & {V < 2^{{p\; 2} - 1}} \\2^{{p\; 2} - 1} & {2^{{p\; 2} - 1} \leq V \leq {2^{{p\; 2} - 2} \times 3}} \\{2^{{p\; 2} + 1} - {2 \times V}} & {V > 2^{{p\; 2} - 1}}\end{matrix},} \right.$

where V is a value of the lightness, and a value of p2 is obtainedaccording to a maximum value 2^(p2)−1 of the value V of the lightness ofthe HSV space.

Preferably, the color classification module is configured to perform, byusing the following formula, downsampling on the display units includedin the picture:

${\left\lbrack {S_{1}^{\prime},S_{2}^{\prime},{\ldots\mspace{14mu} S_{T}^{\prime}}} \right\rbrack = \left\lbrack {\left\lfloor \frac{S_{1}}{2^{q\; 1}} \right\rfloor,\left\lfloor \frac{S_{2}}{2^{q\; 1}} \right\rfloor,\ldots\mspace{14mu},\left\lfloor \frac{S_{T}}{2^{q\; 1}} \right\rfloor} \right\rbrack},$

and classify display units that are obtained after downsampling and thathave same [S₁′, S₂′, . . . S_(T)′] into a same color category,

where T is a quantity of dimensions of the first color space, [S₁, . . ., S_(T)] is a value of a single display unit in the first color space,q1 is an integer greater than 0 and less than p, and a value of p isobtained according to a known maximum value 2^(p)−1 of each dimension inthe first color space.

Preferably, the dominant-color extraction module is configured tomultiply the quantity of display units corresponding to each colorcategory by the weight to obtain a color value of each color category.

Preferably, the dominant-color extraction module is configured toextract an intermediate color value of a color category that has alargest color value to serve as the dominant color of the picture.

Preferably, the apparatus further includes a picture downscaling module,configured to reduce side pixels of the picture to a proper value.

Preferably, the apparatus further includes: a module for matching atemplate to determine a final dominant color, configured to: match theextracted dominant color of the picture with a pre-configured templatecolor, and select a template color nearest to the dominant color of thepicture as the final dominant color of the picture.

According to a third aspect of the present invention, an embodiment ofthe present invention provides a method for changing a background colorof an element bar with a dominant color of a picture, including:

transparentizing a background color of an element bar of a currentlyrunning application;

extracting a dominant color of a picture currently displayed on a userinterface of the application; and

using the extracted color as the background color of the element bar anddisplaying the extracted color.

Preferably, the method further includes: automatically changing a buttoncolor of the element bar according to the changed background color ofthe element bar.

Preferably, the step of extracting a dominant color of a currentlydisplayed picture includes:

a picture obtaining step for obtaining the currently displayed picture,where the picture includes multiple display units;

a color classification step for performing, in a first color space,classification processing on each display unit included in the pictureso as to obtain several color categories by classifying display unitshaving same color characteristics into a same color category, andcalculating a quantity of display units corresponding to each colorcategory;

a color-weight calculation step for converting each color category fromthe first color space to a second color space, obtaining a value of eachcolor category in each dimension of the second color space, determininga weighting function of each dimension of the second color spaceaccording to a factor that is in a display requirement and thatcorresponds to each dimension of the second color space, and calculatinga weight of each color category according to the value of each colorcategory in each dimension of the second color space and the weightingfunction of each dimension; and

a dominant-color extraction step for calculating color values accordingto the quantity of display units corresponding to each color categoryand the weight of the color category, and extracting a color categoryhaving a highest color value to serve as the dominant color of thepicture.

Preferably, the element bar includes: a title bar, a menu bar, anaddress bar, a status bar, a taskbar, or a browsing bar.

According to a fourth aspect of the present invention, an embodiment ofthe present invention provides an apparatus for changing a backgroundcolor of an element bar with a dominant color of a picture, including:

a module for transparentizing a background color of an element bar,configured to transparentize a background color of an element bar of acurrently running application;

a module for extracting a dominant color of a picture, configured toextract a dominant color of a picture currently displayed on a userinterface of the application; and

a module for changing a background color of an element bar, configuredto use the extracted color as the background color of the element barand display the extracted color.

Preferably, the apparatus further includes: a module for changing abutton color of an element bar, configured to automatically change abutton color of the element bar according to the changed backgroundcolor of the element bar.

Preferably, the element bar includes: a title bar, a menu bar, anaddress bar, a status bar, a taskbar, or a browsing bar.

By means of the method and the apparatus for changing a background colorof a toolbar with a dominant color of a picture described in the presentinvention, an extracted dominant color of a picture may be applied to aconventionally fixed background color of a toolbar, so that a color ofthe toolbar may be adaptively adjusted according to result contentdisplayed on a screen. Therefore, an interface match is more harmoniousand beautiful. Overall harmony and a subject correlation of theinterface are enhanced. Disadvantages of a relatively rigid overall lookand a relatively strong sense of being cut apart of the displayinterface in the prior art are avoided. An effect of interface immersiveexperience is improved, and the interface is more visually harmonious.

BRIEF DESCRIPTION OF THE DRAWINGS

The present invention will become more fully understood from thedetailed description given herein below for illustration only, and thusare not limitative of the present invention, and where:

FIG. 1 is a schematic flowchart of a method for changing a backgroundcolor of a toolbar with a dominant color of a picture according to thepresent invention;

FIG. 2 is a flowchart of a method for extracting a dominant color of apicture according to an embodiment of the present invention;

FIG. 3 is a flowchart of a method for extracting a dominant color of apicture according to another embodiment of the present invention;

FIG. 4 is a block diagram of an apparatus for changing a backgroundcolor of a toolbar with a dominant color of a picture according to thepresent invention;

FIG. 5 is a block diagram of a module for extracting a dominant color ofa picture according to an embodiment of the present invention;

FIG. 6 is a block diagram of a module for extracting a dominant color ofa picture according to another embodiment of the present invention;

FIG. 7 is an example of a screenshot of screen display in the prior art;and

FIG. 8 is an example of a screenshot of screen display after a method oran apparatus in the present invention is used.

DETAILED DESCRIPTION

The technical solutions in the embodiments of the present invention areclearly and completely described below with reference to theaccompanying drawings in the embodiments of the present invention.Apparently, the described embodiments are merely a part rather than allof the embodiments of the present invention. Usually, components thatare of the embodiments of the present invention and that are describedand shown in the accompanying drawings may be arranged and designed byusing various different configurations. Therefore, the followingdetailed descriptions about the embodiments of the present inventionprovided in the accompanying drawings are not intended to limit thescope of the present invention protected by the claims, but are merelyused to represent selected embodiments of the present invention. Allother embodiments obtained by a person of ordinary skill in the artbased on the embodiments of the present invention without creativeefforts shall fall within the protection scope of the present invention.

The technical solutions in the embodiments of the present invention areclearly and completely described below with reference to theaccompanying drawings and specific embodiments of the present invention.

FIG. 1 is a schematic flowchart of a method for changing a backgroundcolor of a toolbar with a dominant color of a picture according to thepresent invention. As shown in FIG. 1, the method for changing abackground color of a toolbar with a dominant color of a picture in thepresent invention includes the following steps.

Step 1: Transparentize a Background Color of a Toolbar of a CurrentlyRunning Application.

As mentioned in the related art, a background color of a toolbar of anexisting APP at a client site is fixed. Therefore, when the existing APPat a client site displays a big picture in a full screen or almost in afull screen, colors displayed on a screen of an intelligent terminallook rigid, and have a relatively strong sense of being cut apart.Therefore, the background color of the toolbar of a currently runningapplication needs to be transparentized first, so that a color of thepicture that is blocked by the toolbar and that is currently displayedon the screen becomes visible. In different program languageenvironments, a related parameter of a corresponding function is set totransparentize the background color of the toolbar. A person skilled inthe art knows how to set the parameter, and details are not describedherein.

Step 2: Extract a Dominant Color of the Picture Currently Displayed on aUser Interface of the Application.

There are many methods for extracting a dominant color of a picture. Forexample, the patent No. CN101714257A disclosed on May 26, 2010 disclosesan extraction and structured description method for a main color featureof a picture; the patent No. CN102592272A disclosed on Jul. 18, 2012discloses a method and an apparatus for extracting a dominant tone of apicture; the patent No. CN104123736A disclosed on Oct. 29, 2014discloses a method and an apparatus for obtaining a main color system ofa picture; and the patent No. CN104268904A disclosed on Jan. 7, 2015discloses a method and an apparatus for extracting a dominant color of apicture, and more examples are not listed herein. In addition to themethod for extracting a dominant color of a picture known in the art,the present invention further provides a new method for extracting adominant color of a picture. A specific implementation method forextracting a dominant color of a picture provided in the presentinvention is described in detail below.

Step 3: Use the Extracted Color as the Background Color of the Toolbar,and Display the Extracted Color.

A person skilled in the art knows that various colors displayed on ascreen of an intelligent terminal are implemented by setting, forexample, different RGB color values or combinations thereof. Therefore,the color extracted in step 2 may be represented by a specific colorvalue. The background color value of the toolbar is replaced with theextracted color value, so that the extracted color is used as thebackground color of the toolbar and is displayed.

When the background color of the toolbar is changed, an original buttoncolor may not be consistent with the background color of the toolbar,that is, in the new background color of the toolbar, a button may not beclearly displayed. For example, the original button color is black, andthe background color of the toolbar is in a dark-colored area.Therefore, in a preferable solution, the method for changing abackground color of a toolbar with a dominant color of a picture mayfurther include:

Step 4: Automatically Change a Button Color of the Toolbar According tothe Changed Background Color of the Toolbar.

The button color of the toolbar is automatically changed according tothe changed background color of the toolbar by using acolor-to-grayscale method. The color-to-grayscale method includes:

using a formula Gray=R*0.299+G*0.587+B*0.114, where Gray is a grayscalevalue, R is a red color value of the extracted dominant color of thepicture, G is a green color value of the extracted dominant color of thepicture, and B is a blue color value of the extracted dominant color ofthe picture; and converting the RGB color values of the extracteddominant color of the picture to a grayscale value, where when thegrayscale value ranges from 0 to 0.5, the button color of the toolbar isautomatically changed to black, and when the grayscale value ranges from0.5 to 1, the button color of the toolbar is automatically changed towhite. Specifically, the formula Gray=R*0.299+G*0.587+B*0.114 is afamous psychology formula known in the field. After the RGB color valuesare converted to the grayscale value by using the foregoing formula, ifthe grayscale value ranges from 0 to 0.5, it indicates that the dominantcolor of the picture currently displayed on the screen is in a lightarea. Therefore, the button color of the toolbar is changed to black.When the grayscale value ranges from 0.5 to 1, it indicates that thedominant color of the picture currently displayed on the screen is in adark area. Therefore, the button color of the toolbar should be changedto white.

In addition, in a preferable embodiment, when a user operates an APP ata client site installed on an intelligent terminal, displayed contentmay be scrolled up and down or left and right, paged up or down,switched, or the like. For example, when browsing a web page by using abrowser installed on the intelligent terminal, a user slides the screenwith a finger to scroll, page up or down, or switch displayed web pagecontent. Several scenarios may occur: (1) The user slightly slides thescreen with a finger to slightly move the displayed picture. That is,although the picture displayed on the screen is moved, the picture isstill completely displayed in a display area of the screen. The dominantcolor of the picture has been extracted and is used as the backgroundcolor of the toolbar for display. In this case, the background color ofthe toolbar remains unchanged. (2) The user slides the screen to scrollthe displayed picture on the screen, and in the end, a text or a blankpage is displayed on the screen instead of the picture. In this case,the background color of the toolbar is recovered to a default color. (3)The user slides the screen with a finger to scroll the displayed pictureon the screen, and ends with a new picture displayed on the screen, thebackground color of the toolbar is adaptively changed. That is, steps 1to 3 or steps 1 to 4 of the foregoing method are performed to change thebackground color of the toolbar to a new color.

In addition, in a preferable embodiment, if a user sets a backgroundcolor of an running APP at a client site, for example, the user sets abackground color of a browser installed on an intelligent terminal togreen, and a web page opened on the browser displays a text content andthe background color is green. A background color of a toolbar of thebrowser may also be adaptively changed by running the foregoing method.

In short, after step 3 or step 4 of the method for changing a backgroundcolor of a toolbar with a dominant color of a picture is finished, themethod further includes:

when the displayed picture is moved up and down or left and right with auser operation, keeping the background color of the toolbar unchangedwhen the displayed picture is not completely moved out of an operationinterface; and recovering the background color of the toolbar to adefault color when the displayed picture is completely moved out of theoperation interface and the operation interface does not have a pictureor a color to display.

It should be noted that the currently displayed picture described inthis specification is a main big picture that is displayed on the screenof the intelligent terminal and that occupies a dominant position. Thatis, the displayed picture occupies all or most of the display area ofthe screen.

By means of the method for changing a background color of a toolbar witha dominant color of a picture described in the present invention, anextracted dominant color of a picture may be applied to a conventionallyfixed background color of a toolbar, so that a color of the toolbar maybe adaptively adjusted according to result content displayed on ascreen. Therefore, an interface match is more harmonious and beautiful.The overall harmony and subject correlation of the interface areenhanced. Disadvantages of a relatively rigid overall look and arelatively strong sense of being cut apart of the display interface inthe prior art are avoided. An effect of interface immersive experienceis improved, and the interface is more visually harmonious.

For example, FIG. 7 is an example of a screenshot of screen display inthe prior art. The screenshot displayed in FIG. 7 is a page of weatherforecast browsed by using a browser at a client site on an intelligentterminal. As can be seen, a color of a picture displayed on the page ismainly blue, but a background color of a bottom toolbar of the browseris always white. Consequently, an overall look of the display interfaceis relatively rigid, and it feels like that the display interface is cutapart. FIG. 8 is an example of a screenshot of screen display after themethod or the apparatus in the present invention is used. As can be seenfrom a page of weather forecast shown in FIG. 8, when a color of apicture displayed on the page is mainly blue, a background color of abottom toolbar is automatically changed to blue. The background color ofthe bottom toolbar is consistent with a style of the color of thepicture of the page displayed on the screen. An interface is morevisually harmonious. The overall harmony and subject correlation of theinterface are enhanced.

In addition, although the method for changing a background color of atoolbar with a dominant color of a picture is described in multipleembodiments described above, a person skilled in the art knows that themethod is not limited to a background color of a toolbar. Backgroundcolors of other element bars may also be changed with a dominant colorof a picture by using the method provided in the embodiments of thepresent invention. The element bar includes but is not limited to: atitle bar, a menu bar, an address bar, a status bar, a taskbar, abrowsing bar, or the like.

Therefore, an embodiment of the present invention further provides amethod for changing a background color of an element bar with a dominantcolor of a picture, including:

transparentizing a background color of an element bar of a currentlyrunning application;

extracting a dominant color of a picture currently displayed on a userinterface of the application; and

using the extracted color as the background color of the element bar anddisplaying the extracted color.

Preferably, the method further includes: automatically changing a buttoncolor of the element bar according to the changed background color ofthe element bar. The element bar includes: a title bar, a menu bar, atoolbar, an address bar, a status bar, a taskbar, or a browsing bar.

In addition, any combination solution of multiple embodiments describedabove is also applicable to this embodiment.

In addition, as described in the foregoing step 2, the dominant color ofthe currently displayed picture may be extracted by using multiplemethods. FIG. 2 is a flowchart of a method for extracting a dominantcolor of a picture according to an embodiment of the present invention.As shown in FIG. 2, in a preferable embodiment, the method forextracting a dominant color of a picture provided in the presentinvention includes:

a picture obtaining step 201 for obtaining the currently displayedpicture, where the picture includes multiple display units;

a color classification step 202 for performing, in first color space,classification processing on each display unit included in the pictureso as to obtain several color categories by classifying display unitshaving same color characteristics into a same color category, andcalculating a quantity of display units corresponding to each colorcategory;

a color-weight calculation step 203 for converting each color categoryfrom the first color space to second color space, obtaining a value ofeach color category in each dimension of the second color space,determining a weighting function of each dimension of the second colorspace according to a factor that is in a display requirement and thatcorresponds to each dimension of the second color space, and calculatinga weight of each color category according to the value of each colorcategory in each dimension of the second color space and the weightingfunction of each dimension; and

a dominant-color extraction step 204 for calculating color valuesaccording to the quantity of display units corresponding to each colorcategory and the weight of the color category, and extracting a colorcategory having a highest color value to serve as the dominant color ofthe picture.

In addition, in a preferable embodiment, before the color classificationstep, the method further includes: a step of scaling down the picture,in order to reduce side pixels of the picture to a proper value.

In addition, in another preferable embodiment, in addition to the stepsdescribed above, the method for extracting a dominant color of a picturein the present invention further includes: a step of matching a templatefor matching the extracted dominant color of the picture with apre-configured template color, and selecting a template color nearest tothe dominant color of the picture as the final dominant color of thepicture.

FIG. 3 is a flowchart of a method for extracting a dominant color of apicture according to another embodiment of the present invention. FIG. 3shows the method for extracting a dominant color of a picture includingthe two foregoing preferable embodiments. However, a person skilled inthe art knows after reading this specification of the present inventionthat the two preferable embodiments may separately and individually bein the method embodiment shown in FIG. 2, or may be in the methodembodiment shown in FIG. 2 together.

Details of the foregoing steps are described below with reference toFIG. 3.

First, in step S201, a currently displayed picture is obtained, wherethe picture includes multiple display units.

The currently displayed picture is usually a main picture displayed whenweb page content is browsed on a web page, or a main picture displayedon an interface of a third-party application, for example, a mobilephone application.

The picture includes multiple display units. The display units may beminimum pixel units displayed in the picture, may be minimum arrays ofpicture data, or may be display units of picture processing that aredivided according to an application need. For example, minimum displayareas of the picture that can support an operation are divided accordingto an operation capability supported by an apparatus for implementingthe method for extracting a dominant color of a picture.

Subsequently, optionally, step S202 is performed to perform the step ofscaling down the picture for reducing side pixels of the picture to aproper value. Step S202 is preferable, and implementation of the methodfor extracting a dominant color of a picture is not affected withoutperforming this step.

If a size of the currently displayed picture is relatively big or aprocessing capability of the apparatus for implementing the method forextracting a dominant color of a picture is limited, the side pixels ofthe picture whose dominant color is to be extracted may be reduced to aproper value by using step S202, so that the size of the picture isreduced to a size suitable for processing or a size suitable for theprocessing capability of the apparatus for implementing the method forextracting a dominant color of a picture. The proper value may beselected according to an application need or practice experience. Ingenerally application, it is relatively suitable to reduce the side ofthe picture to 200 pixels.

If the size of the picture whose dominant color is to be extracted issuitable or the processing capability of the apparatus of the method forextracting a dominant color of a picture is not limited, step S203 isdirectly performed after step S201, where S203 is the colorclassification step for performing, in the first color space,classification processing on each display unit included in the pictureso as to obtain several color categories by classifying display unitshaving same color characteristics into a same color category, andcalculating a quantity of display units corresponding to each colorcategory.

The first color space may be an RGB space, where R represents red, Grepresents green, and B represents blue. In the RGB space, three colors,red (R), green (G), and blue (B), are changed or overlapped to obtainvarious colors. Therefore, in the RGB space, which is three-dimensionalspace, various colors that can be seen by humans may be represented by acombination of different values of three dimensions R, G, and B. Thefirst color space may be other color space in which various colors thatcan be seen by humans may be represented by using a combination ofvalues of dimensions of the space, for example, LAB space. In the LABspace, L represents lightness, (which ranges from 0 to 100), Arepresents a range from red to green (which ranges from 127 to −128,where 127 corresponds to red, and −128 corresponds to green), and Brepresents a range from yellow to blue (which ranges from 127 to −128,where 127 corresponds to yellow, and −128 corresponds to blue). Allcolors may be formed in the LAB space by changing a combination of thethree values L, A, and B.

The color characteristic may be a characteristic used to independentlyrepresent a common point of colors of multiple display units in thefirst color space, may be a value range of a dimension in the firstcolor space, or may be a combination including at least value ranges ofany two dimensions in the first color space, or another equivalentcharacteristic.

For example, the first color space is the RGB space. Display unitssatisfying a color characteristic that a value of R ranges from 16 to 31may be classified into a same color category, and display unitssatisfying a color characteristic that a value of R ranges from 0 to 15may be classified into another color category. By analogy, the displayunits included in the picture are classified according to the colorcharacteristic of the value of the dimension R. Alternatively,classification is performed according to a color characteristic ofvalues of two dimensions R and G. For example, display units satisfyinga color characteristic that the values of both R and G range from 16 to31 are classified into a same color category, display units satisfying acolor characteristic that the values of both R and G range from 0 to 15are classified into another color category, and so on, to finishclassification. Alternatively, classification is performedsimultaneously according to a color characteristic of values of threedimensions R, G, and B. For example, display units satisfying a colorcharacteristic that values of R, G, and B range from 16 to 31 areclassified into a same color category, display units satisfying a colorcharacteristic that the values of R, G, and B range from 0 to 15 areclassified into another color category, and so on, to finishclassification.

Therefore, when the first color space is the RGB space, the colorclassification step of step S203 is specifically performing, in the RGBspace, classification processing on each display unit included in thepicture so as to obtain several color categories by classifying displayunits having same color characteristics in the RGB space into a samecolor category, and calculating a quantity of display unitscorresponding to each color category. The color characteristic is avalue range of any dimension in the RGB space or a combination includingat least value ranges of any two dimensions in the RGB space.

There may be multiple classification methods. As described above, amethod of obtaining values in segments according to an interval range ofat least one dimension of the first color space may be used. Preferably,downsampling may be performed on the display units in the picture byusing the following Formula 1, to classify the display units:

$\begin{matrix}{{\left\lbrack {S_{1}^{\prime},S_{2}^{\prime},{\ldots\mspace{14mu} S_{T}^{\prime}}} \right\rbrack = \left\lbrack {\left\lfloor \frac{S_{1}}{2^{q\; 1}} \right\rfloor,\left\lfloor \frac{S_{2}}{2^{q\; 1}} \right\rfloor,\ldots\mspace{14mu},\left\lfloor \frac{S_{T}}{2^{q\; 1}} \right\rfloor} \right\rbrack},} & \left( {{Formula}\mspace{14mu} 1} \right)\end{matrix}$

Display units that are obtained after downsampling and that have same[S₁′, S₂′, . . . S_(T)′] are classified into a same color category,

where T is a quantity of dimensions of the first color space [S₁, . . ., S_(T)], is a value of a single display unit in the first color space,q1 is an integer greater than 0 and less than p, and a value of p may beobtained according to a known maximum value 2^(p)−1 of each dimension inthe first color space.

For example, the first color space is the RGB space, downsampling isperformed, by using the following formula, on the display units includedin the picture:

${\left\lbrack {S_{R}^{\prime},S_{G}^{\prime},S_{B}^{\prime}} \right\rbrack = \left\lbrack {\left\lfloor \frac{S_{R}}{2^{q\; 1}} \right\rfloor,\left\lfloor \frac{S_{G}}{2^{q\; 1}} \right\rfloor,\left\lfloor \frac{S_{T}}{2^{q\; 1}} \right\rfloor} \right\rbrack},$and display units that are obtained after downsampling and that havesame [S_(R)′,S_(G)′,S_(B)′] are classified into a same color category.

[S_(R),S_(G),S_(B)] is a value of a single display unit in the RGBspace, q1 is an integer greater than 0 and less than p, and the value ofp may be obtained according to the maximum value 2^(p)−1 of eachdimension in the RGB space.

For a further detailed explanation, the first color space is set as anRGB256 space (values of R, G, and B range from 0 to 255). It is assumedthat a value of a display unit A in the picture is[S_(R),S_(G),S_(B)]=[120, 56, 56] in the RGB space, and a value ofanother display unit B is [S_(R),S_(G),S_(B)]=[124,50,60] in the RGBspace. A downsampling is performed on the display units A and B by usingthe foregoing method. It may be determined that the value of p is 8according to that a value of each dimension in the RGB space ranges from0 to 255, that is, 2^(p)−1=255. Therefore, it may be known that p=8, anda value of p1 is selected to be 4 (an integer greater than 0 and lessthan 8):

for the display unit A:

${\left\lbrack {S_{R}^{\prime},S_{G}^{\prime},S_{B}^{\prime}} \right\rbrack = {\left\lbrack {\left\lfloor \frac{120}{2^{4}} \right\rfloor,\left\lfloor \frac{56}{2^{4}} \right\rfloor,\left\lfloor \frac{56}{2^{4}} \right\rfloor} \right\rbrack = \left\lbrack {7,3,3} \right\rbrack}},$and

for the display unit B:

$\left\lbrack {S_{R}^{\prime},S_{G}^{\prime},S_{B}^{\prime}} \right\rbrack = {\left\lbrack {\left\lfloor \frac{124}{2^{4}} \right\rfloor,\left\lfloor \frac{50}{2^{4}} \right\rfloor,\left\lfloor \frac{60}{2^{4}} \right\rfloor} \right\rbrack = {\left\lbrack {7,3,3} \right\rbrack.}}$

The two display units have equivalent [S_(R)′,S_(G)′,S_(B)′] obtainedthrough downsampling, and therefore, are classified into a same colorcategory.

Step S204, which is a color-weight calculation step, is performed forconverting each color category from the first color space to the secondcolor space, obtaining a value of each color category in each dimensionof the second color space, determining a weighting function of eachdimension of the second color space according to a factor that is in adisplay requirement and that corresponds to each dimension of the secondcolor space, and calculating a weight of each color category accordingto the value of each color category in each dimension of the secondcolor space and the weighting function of each dimension.

The second color space is usually color space different from the firstcolor space. For example, the first color space is an RGB space or LABspace, and the second color space may be an HSV space, HIS space, or YUVspace. The HSV space is three-dimensional color space and has threedimensions: hue H, saturation rate S, and brightness V. In the HSIspace, a combination of three dimensions H, S, and I is used torepresent a color. H defines a wavelength color tone (that is, a colortone) of a color, S represents a degree of darkness (that is, thesaturation rate) of a color, and I represents intensity or brightness.In the YUV space, Y represents brightness (that is, a grayscale). U andV represent chrominance, express color tone or a saturation rate of acolor, and form two components of a color.

The first color space may be converted to the second color space byusing a known color space conversion algorithm. For example, when an RGBspace is converted to an HSV space, an OpenCv crypto library may beused. This is not limited in the present invention.

The display requirement may be diversified. For example, the displayrequirement may include one or more factors. For example, a color of apicture is relatively bright, or an extreme color such as blood red isavoided being seen, or an extreme color unfavorable to text display isavoided. When a picture is displayed, there may be a display requirementonly having a single factor, or there may be a display requirementhaving multiple factors.

An example in which the second color space is the HSV space is used. TheHSV space is three-dimensional space, and has three dimensions: hue H,saturation rate S, and lightness V. If the display requirement includesa factor that a color of a picture is relatively bright, and the factorcorresponds to the saturation rate S of the HSV space, a weightingfunction of the saturation rate needs to be set. For another example, ifthe display requirement includes a factor that an extreme color such asblood red does not show up in a picture, and the factor corresponds tothe hue H of the HSV space, a weighting function of the hue needs to beset. For another example, if the display requirement includes a factorof avoiding an extreme color unfavorable to text display, and the factorcorresponds to the lightness V of the HSV space, a weighting function ofthe lightness needs to be set.

Further, if the display requirement includes the factor that a color ofa picture is relatively bright, the weighting function of the saturationrate S needs to be set. The weighting function of the saturation ratemay be set to a quadratic function of the saturation rate value S, sothat the factor, included in the display requirement, that a color of apicture is relatively bright can be highlighted in a result valuecalculated by the saturation rate function. For another example, if thedisplay requirement includes a factor that a color of a picture isrelatively soft, the weighting function of the saturation rate S needsto be set. The weighting function of the saturation rate may be set to alinear function or a constant term of the saturation rate value S, sothat the factor, included in the display requirement, that a color of apicture is relatively soft can be highlighted in a result valuecalculated by the saturation rate function. For another example, thedisplay requirement includes the factor that an extreme color such asblood red does not show up in a picture. The factor corresponds to thehue H of the HSV space, and the factor requires that a color fallingwithin a value range of H corresponding to blood red cannot be thedominant color. The weighting function of the hue needs to be set, sothat blood red can be removed from a result value calculated by theweighting function of the hue. For another example, if the displayrequirement includes the factor of avoiding an extreme color unfavorableto text display, and the factor corresponds to the lightness V of theHSV space, the weighting function of the lightness V needs to be set.The weighting function of the lightness may be set to a linear function,so that an extreme color unfavorable to text display may be avoided in aresult value calculated by the weighting function of the lightness. Theforegoing examples are merely exemplary. The present invention is notlimited thereto. A person skilled in the art may change, according to anactual application scenario or need, the method for implementing thepresent invention.

Preferably, the N color categories obtained in step S203 are convertedfrom the first color space to the second color space having Mdimensions, to obtain a value of each color category in the second colorspace, where an i^(th) color category in a j^(th) dimension of thesecond color space is P_(ij)(i=1, . . . , N; j=1, . . . , M). Theweighting function of each dimension of the second color space is setaccording to the factor that is in the display requirement and thatcorresponds to each dimension of the second color space, where aweighting function of the j^(th) dimension is F(x_(j))(j=1, . . . , N).Then, the weight of each color category is calculated according to thevalue and the weighting function of each color category in the secondcolor space, where a weight W_(i) of the i^(th) category of color is:

$\begin{matrix}{W_{i} = {{\sum\limits_{j = 1}^{M}{F\left( P_{ij} \right)}} + C}} & \left( {{Formula}\mspace{14mu} 2} \right)\end{matrix}$

where C is a constant except 0.

A value of C may be selected according to an application need orpractice experience. For example, C=1.

An example in which the first color space is an RGB space, and thesecond color space is HSV space is used for further description. Eachcolor category obtained through classification in the RGB space isconverted from the RGB space to the HSV space. The HSV space is athree-dimensional color space. In this example, a value range of H space(hue of a color) is [0, 179], which represents a color circle; a valuerange of S space (color saturation rate) is [0, 255], where a largervalue indicates a higher saturation rate; and a value range of V space(color lightness) is [0, 255], where a larger value indicates higherlightness.

The N color categories obtained through classification in step S203 areconverted from the RGB space to the HSV space having three dimensions,to obtain values of each color category in hue H, saturation rate S, andlightness V of the HSV space, where a value of an i^(th) color categoryis [H_(i), S_(i), V_(i)] A weighting function of each dimension of theHSV space is set according to a factor that is in the displayrequirement and that corresponds to each dimension of the HSV space,where a weighting function of the hue is F(H), a weighting function ofthe saturation rate is F(S), and a weighting function of the lightnessis F(V). A weight of each color category is calculated according to thevalue of each color category in the HSV space and the weightingfunction, where a weight W_(i) of the i^(th) color category is:W _(i) =F(H _(i))+F(S _(i))+F(V _(i))+C  (Formula 3)

where C is a constant except 0.

A value of C may be selected according to an application need orpractice experience. For example, C=1.

Preferably, the weighting function is set so that a dimension having ahigher correlation with a factor in the display requirement indicates alarger result value calculated by the weighting function of thedimension.

An example in which the second color space is the HSV space is used. Thedisplay requirement includes the factor that a color of a picture isrelatively bright, and among the hue H, the saturation rate S, and thelightness V in the HSV space, the saturation rate S has a highestcorrelation with the factor. Therefore, the weighting function of thesaturation rate may be set to a quadratic function of the saturationrate value S, and the weighting function of the hue and the weightingfunction of the lightness may be set to monomial terms, constant terms,or even 0, so that a result value calculated by the weighting functionof the saturation rate is greater than a result value calculated by theweighting function of the hue and a result value calculated by theweighting function of the lightness.

For another example, the display requirement includes the factor ofavoiding an extreme color unfavorable to text display, and among the hueH, the saturation rate S, and the lightness V in the HSV space, thelightness V has a highest correlation with the factor. Therefore, theweighting function of the lightness may be set to a linear function ofthe lightness value V, and the weighting function of the hue and theweighting function of the saturation rate may be set to monomial terms,constant terms, or even 0, so that a result value calculated by theweighting function of the lightness is greater than a result valuecalculated by the weighting function of the hue and a result valuecalculated by the weighting function of the saturation.

The foregoing examples are merely exemplary. The present invention isnot limited thereto. A person skilled in the art may change, accordingto an actual application scenario or need, the method for implementingthe present invention.

Preferably, when the factor corresponding to the saturation rate of theHSV space in the display requirement is making a displayed colorbrighter, the weighting function of the saturation rate is set to:F(S)=(S/2^(A))²  (Formula 4)

where S is a value of the saturation rate, and A is a positive integer.

For example, it is selected, according to application experience, thatA=3. The weighting function of the saturation rate is F(S)=(S/8)²according to formula 4.

In addition, the factor of making a displayed color brighter in thedisplay requirement has a relatively high corresponding correlation withthe saturation rate of the HSV space, that is, higher than correspondingcorrelations with the hue H and the lightness V in the displayrequirement. F(H) and F(V) may be set to monomial terms or constantterms, so that a result value calculated by F(S) is relatively large.

For example, in some applications, if there is no factor correspondingto the hue and the lightness in the display requirement, and there isonly the factor corresponding to the saturation rate and that is makinga displayed color brighter, F(H) and F(V) are set to 0. According toFormula 3 and Formula 4, the weight W_(i) of the i^(th) color categoryis W_(i)=(S_(i)/A)²+C, where S_(i) is a saturation rate value of thei^(th) category of color, and C is a constant except 0.

Preferably, when a factor corresponding to the lightness of the HSVspace in the display requirement is avoiding an extreme colorunfavorable to text display, a weighting function of the lightness isset to:

$\begin{matrix}{{F(V)} = \left\{ \begin{matrix}V & {V < 2^{{p\; 2} - 1}} \\2^{{p\; 2} - 1} & {2^{{p\; 2} - 1} \leq V \leq {2^{{p\; 2} - 2} \times 3}} \\{2^{{p\; 2} + 1} - {2 \times V}} & {V > 2^{{p\; 2} - 1}}\end{matrix} \right.} & \left( {{Formula}\mspace{14mu} 5} \right)\end{matrix}$

where V is a value of the lightness, and a value of p2 is obtainedaccording to a maximum value 2^(p2)−1 of the value V of the lightness ofthe HSV space.

For example, the maximum value of the lightness V in the HSV space inthe example is 255, that is, 2^(p2)−1=255. Correspondingly, p2=8.According to formula 5, the weighting function of the lightness is:

${F(V)} = \left\{ \begin{matrix}V & {V < 128} \\128 & {128 \leq V \leq 192} \\{512 - {2 \times V}} & {V > 128}\end{matrix} \right.$

In addition, for the factor of an extreme color unfavorable to textdisplay in the display requirement, a correlation corresponding to thelightness of the HSV space is higher, that is, higher than correlationscorresponding to the hue H and the saturation rate S in the displayrequirement. F(H) and F(S) may be set to monomial terms or constantterms, so that a result value calculated by F(S) is larger.

For example, in some applications, if there is no factor correspondingto the hue and the saturation rate in the display requirement, and thereis merely a factor corresponding to the lightness, F(H) and F(S) are setto 0. According to Formula 3 and Formula 5, the weight W_(i) of i^(th)color category is:

$W_{i} = \left\{ {\begin{matrix}{V_{i} + C} & {V_{i} < 2^{{p\; 2} - 1}} \\{2^{{p\; 2} - 1} + C} & {2^{{p\; 2} - 1} \leq V_{i} \leq {2^{{p\; 2} - 2} \times 3}} \\{2^{{p\; 2} + 1} - {2 \times V_{i}} + C} & {V_{i} > 2^{{p\; 2} - 1}}\end{matrix},} \right.$

where V_(i) is the value of the lightness of the i^(th) color category.

Subsequently, step S205, which is a dominant-color extraction step, isperformed for calculating color values according to the quantity ofdisplay units corresponding to each color category and the weight of thecolor category, and extracting a color category having a highest colorvalue to serve as the dominant color of the picture.

In the present invention, the color value represents an evaluation oneach color category, and is comprehensively determined according to theweight of each color category that is obtained by using the displayrequirement and the quantity of display units corresponding to eachcolor category. Among the colors that satisfy the display requirement, acolor having a largest color value is a color that includes a largestquantity of display units (that is, the quantity of correspondingdisplay units) in the picture. Therefore, the category of color servesas the dominant color of the picture.

The color value is calculated according to the quantity of display unitscorresponding to each color category and the weight of the colorcategory. The color value may be a value obtained by simply multiplyingthe quantity of display units corresponding to each color category bythe weight of the color category, or may be a value obtained bymultiplying the quantity of display units corresponding to each colorcategory by the weight of the color category and then multiplying ordividing a proportionality coefficient. The proportionality coefficientmay be selected according to an application need or may be selectedaccording to a processing capability of an apparatus for implementingcalculation. Alternatively, another equivalent calculation method may beused, provided that a result of the color value of each color categoryobtained through calculation is an evaluation on each color category,that is based on a same evaluation criterion and that embodies thequantity of display units corresponding to each color category and theweight of each color category that is obtained according to the displayrequirement.

Preferably, the quantity of display units corresponding to each colorcategory is multiplied by the weight to obtain a value as the colorvalue of each color category.

More preferably, an intermediate color value of a color category thathas a largest color value is extracted to serve as the dominant color ofthe picture.

The intermediate color value of the color category that has the largestcolor value may be a color value corresponding to a display unit in amiddle position obtained after value sorting or another sorting methodis performed on the quantity of display units corresponding to the colorcategory that has the largest color value.

Optionally, step S206, which is a step of matching a template todetermine a final dominant color, is performed for matching theextracted dominant color of the picture with a pre-configured templatecolor, and selecting a template color nearest to the dominant color ofthe picture as the final output dominant color of the picture.

If there is a problem, for example, the extracted dominant color of thepicture is not beautiful or the display requirement is not completelysatisfied after step S205, step S206 may be performed to match thedominant color of the picture with a template and select a templatecolor nearest to the dominant color of the picture as the final dominantcolor of the picture, so that the finally output dominant color of thepicture satisfies user aesthetics or completely satisfies the displayrequirement.

The pre-configured template color may be selected according to thedisplay requirement. For example, a color set having good userexperience is selected to be the template color. Dazzling blood red isnot included. For an algorithm of matching the dominant color of thepicture with the template color, a method for calculating colorsimilarity that is proposed by John R. Smith and Shih-Fu Chang in “afully automated content-based image query system” may be used.

If there is no such problem, for example, the extracted dominant colorof the picture is not beautiful or the display requirement is notsatisfied after step S205, the extracted dominant color of the pictureobtained after step S205 is the final output dominant color of thepicture, and step S206 does not need to be performed.

In conclusion, in the method for extracting a dominant color of apicture provided in the present invention, color classification and acolor weight are used, and a pre-configured template color is auxiliaryused for complement. Therefore, a dominant color of a picture may beobtained more accurately.

FIG. 4 is a block diagram of an apparatus for changing a backgroundcolor of a toolbar with a dominant color of a picture according to thepresent invention. The apparatus may be configured to implement themethod shown in FIG. 1. Therefore, a repeated part is not described indetail again. As shown in FIG. 4, the apparatus for changing abackground color of a toolbar with a dominant color of a pictureincludes:

a module for transparentizing a background color of a toolbar,configured to transparentize a background color of a toolbar of acurrently running application;

a module for extracting a dominant color of a picture, configured toextract a dominant color of a picture currently displayed on a userinterface of the application; and

a module for changing a background color of a toolbar, configured to:use the extracted color as the background color of the toolbar, anddisplay the extracted color.

In addition, in a preferable solution, the apparatus for changing abackground color of a toolbar with a dominant color of a picture mayfurther include:

a module for changing a button color of a toolbar, configured toautomatically change a button color of the toolbar according to thechanged background color of the toolbar. An implementation principle ofthe function is already described in detail in the process of describingstep 4, and is not described herein again.

In addition, in another preferable solution, the apparatus for changinga background color of a toolbar with a dominant color of a picture mayfurther include:

a module for recovering a background color of a toolbar, configured torecover the background color of the toolbar to a default color when thedisplayed picture is completely moved out of an operation interface andthe operation interface does not have a picture or a color to display.

By means of the apparatus for changing a background color of a toolbarwith a dominant color of a picture described in the present invention,an extracted dominant color of a picture may be applied to aconventionally fixed background color of a toolbar, so that a color ofthe toolbar may be adaptively adjusted according to result contentdisplayed on a screen. Therefore, an interface match is more harmoniousand beautiful. Overall harmony and a subject correlation of theinterface are enhanced. Disadvantages of a relatively rigid overall lookand a relatively strong sense of being cut apart of the displayinterface in the prior art are avoided. An effect of interface immersiveexperience is improved, and the interface is more visually harmonious.

In addition, although the apparatus for changing a background color of atoolbar with a dominant color of a picture is described in multipleembodiments described above, a person skilled in the art knows that anapparatus for changing a background color of another element bar with adominant color of a picture may be designed based on the idea. Theanother element bar includes, but is not limited to: a title bar, a menubar, an address bar, a status bar, a taskbar, a browsing bar, or thelike.

Therefore, an embodiment of the present invention further provides anapparatus for changing a background color of an element bar with adominant color of a picture, including:

a module for transparentizing a background color of an element bar,configured to transparentize a background color of an element bar of acurrently running application;

a module for extracting a dominant color of a picture, configured toextract a dominant color of a picture currently displayed on a userinterface of the application; and

a module for changing a background color of an element bar, configuredto use the extracted color as the background color of the element barand display the extracted color.

Preferably, the apparatus further includes: a module for changing abutton color of an element bar, configured to automatically change abutton color of the element bar according to the changed backgroundcolor of the element bar. The element bar includes: a title bar, a menubar, a toolbar, an address bar, a status bar, a taskbar, or a browsingbar.

In addition, any combination solution of multiple embodiments describedabove is also applicable to this embodiment.

FIG. 5 is a block diagram of a module for extracting a dominant color ofa picture according to an embodiment of the present invention. Themodule for extracting a dominant color of a picture may be configured toimplement the method shown in FIG. 2. Therefore, a repeated part is notdescribed in detail again. As shown in FIG. 5, the module for extractinga dominant color of a picture in the present invention includes:

a picture obtaining module, configured to obtain the currently displayedpicture, where the picture includes multiple display units;

a color classification module, configured to: perform, in first colorspace, classification processing on each display unit included in thepicture so as to obtain several color categories by classifying displayunits having same color characteristics into a same color category, andcalculate a quantity of display units corresponding to each colorcategory;

a color-weight calculation module, configured to: convert each colorcategory from the first color space to second color space, obtain avalue of each color category in each dimension of the second colorspace, determine a weighting function of each dimension of the secondcolor space according to a factor that is in a display requirement andthat corresponds to each dimension of the second color space, andcalculate a weight of each color category according to the value of eachcolor category in each dimension of the second color space and theweighting function of each dimension; and

a dominant-color extraction module, configured to: calculate colorvalues according to the quantity of display units corresponding to eachcolor category and the weight of the color category, and extract a colorcategory having a highest color value to serve as the dominant color ofthe picture.

FIG. 6 is a block diagram of a module for extracting a dominant color ofa picture according to another embodiment of the present invention. Themodule shown in FIG. 6 may be configured to implement the method shownin FIG. 3. Therefore, a repeated part is not described in detail again.As shown in FIG. 6, preferably, the module for extracting a dominantcolor of a picture in the present invention may further include: apicture downscaling module and/or a module for matching a template todetermine a final dominant color.

The picture downscaling module is configured to reduce side pixels ofthe picture to a proper value.

The module for matching a template to determine a final dominant coloris configured to: match the extracted dominant color of the picture witha pre-configured template color, and select a template color nearest tothe dominant color of the picture as the final dominant color of thepicture.

Preferably, the color classification module is configured to: perform,by using the following formula, downsampling on the display unitsincluded in the picture:

${\left\lbrack {S_{1}^{\prime},S_{2}^{\prime},{\ldots\mspace{14mu} S_{T}^{\prime}}} \right\rbrack = \left\lbrack {\left\lfloor \frac{S_{1}}{2^{q\; 1}} \right\rfloor,\left\lfloor \frac{S_{2}}{2^{q\; 1}} \right\rfloor,\ldots\mspace{14mu},\left\lfloor \frac{S_{T}}{2^{q\; 1}} \right\rfloor} \right\rbrack},$and classify display units that are obtained after downsampling and thathave same [S₁′, S₂′, . . . S_(T)′] into a same color category, where Tis a quantity of dimensions of the first color space [S₁, . . . , S_(T)]is a value of a single display unit in the first color space, q1 is aninteger greater than 0 and less than p, and a value of p is obtainedaccording to a known maximum value 2^(p)−1 of each dimension in thefirst color space.

Preferably, the color-weight calculation module is configured to:

convert color categories obtained after classification from the firstcolor space to the second color space having M dimensions to obtain avalue of each color category in the second color space, where a value ofan i^(th) color category in a j^(th) dimension of the second color spaceis P_(ij)(i=1, . . . , N; j=1, . . . , M);

set the weighting function of each dimension of the second color spaceaccording to the factor that is in the display requirement and thatcorresponds to each dimension of the second color space, where aweighting function of the j^(th) dimension is F(x_(j))(j=1 . . . , N);and

calculate the weight of each color category according to the value andthe weighting function of each color category in the second color space,where a weight i of the W_(i) _(th) category of color is

${W_{i} = {{\sum\limits_{j = 1}^{M}{F\left( P_{ij} \right)}} + C}},$where C is a constant except 0.

Preferably, the color-weight calculation module is configured to set theweighting function so that a dimension having a higher correlation witha factor in the display requirement indicates a larger result valuecalculated by the weighting function of the dimension.

Preferably, the first color space is different from the second colorspace.

Preferably, when the second color space is an HSV space, thecolor-weight calculation module is configured to: when a factorcorresponding to a saturation rate of the HSV space in the displayrequirement is making a displayed color brighter, set a weightingfunction of the saturation rate to F(S)=(S/2^(A))²,

where S is a value of the saturation rate, and A is a positive integer.

Preferably, when the second color space is the HSV space, thecolor-weight calculation module is configured to: when a factorcorresponding to the lightness of the HSV space in the displayrequirement is avoiding an extreme color unfavorable to text display,set a weighting function of the lightness to:

${F(V)} = \left\{ {\begin{matrix}V & {V < 2^{{p\; 2} - 1}} \\2^{{p\; 2} - 1} & {2^{{p\; 2} - 1} \leq V \leq {2^{{p\; 2} - 2} \times 3}} \\{2^{{p\; 2} + 1} - {2 \times V}} & {V > 2^{{p\; 2} - 1}}\end{matrix},} \right.$

where V is a value of the lightness, and a value of p2 is obtainedaccording to a maximum value 2^(p2)−1 of the value V of the lightness ofthe HSV space.

Preferably, the dominant-color extraction module is configured tomultiply the quantity of display units corresponding to each colorcategory by the weight to obtain a color value of each color category.

More preferably, the dominant-color extraction module is furtherconfigured to extract an intermediate color value of a color categorythat has a largest color value to serve as the dominant color of thepicture.

In conclusion, in the apparatus for extracting a dominant color of apicture provided in the present invention, color classification and acolor weight are used, and a pre-configured template color is auxiliaryused for complement. Therefore, a dominant color of a picture may beobtained more accurately.

It may be clearly understood by a person skilled in the art that, forthe purpose of convenient and brief description, for a detailed workingprocess of the foregoing apparatus, refer to a corresponding process inthe foregoing method embodiments, and details are not described hereinagain.

A computer program product of the method for changing a background colorof a toolbar with a dominant color of a picture provided in thisembodiment of the present invention includes a computer-readable storagemedium storing program code. An instruction included in the program codemay be used to execute the method described in the foregoingembodiments. For specific implementation, refer to the methodembodiments, and details are not described herein again.

When the functions are implemented in the form of a software functionalunit and are sold or used as an independent product, the functions maybe stored in a computer-readable storage medium. Based on such anunderstanding, the technical solutions of the present inventionessentially, or the part contributing to the prior art, or some of thetechnical solutions may be implemented in a form of a software product.The computer software product is stored in a storage medium, andincludes several instructions for instructing a computer device (whichmay be a personal computer, a server, a network device, or the like) toperform all or some of the steps of the methods described in theembodiments of the present invention. The foregoing computer-readablestorage medium includes a U disk, a mobile hard disk, a read-only memory(ROM), a random access memory (RAM), a magnetic disk, or an opticaldisc, or any other medium that can be used for storing program code.

The foregoing descriptions are merely specific implementation manners ofthe present invention, but are not intended to limit the protectionscope of the present invention. Any variation or replacement readilyfigured out by a person skilled in the art within the technical scopedisclosed in the present invention shall fall within the protectionscope of the present invention. Therefore, the protection scope of thepresent invention shall be subject to the protection scope of theclaims.

What is claimed is:
 1. A computer-based method for changing a backgroundcolor of a toolbar in accordance with a dominant color of a picture,comprising: transparentizing, based on an instruction included inprogram code executed by a computing device, a background color of atoolbar of a currently running application; extracting, based on aninstruction included in program code executed by the computing device, adominant color of a picture currently displayed on a user interface ofthe application; displaying, based on an instruction included in programcode executed by the computing device, the toolbar using a color basedon the extracted dominant color as the background color of the toolbar,along with the picture on the user interface of the application, suchthat the toolbar and the picture are displayed harmoniously; and whenthe displayed picture is moved up and down or left and right with a useroperation, keeping the background color of the toolbar unchanged fromthe color based on the extracted dominant color when the displayedpicture is not completely moved out of an operation interface; andrecovering the background color of the toolbar to a default color whenthe displayed picture is completely moved out of the operation interfaceand the operation interface does not have a picture or a color todisplay.
 2. The method according to claim 1, further comprising:automatically changing a button color of the toolbar displayed using thecolor based on the extracted dominant color as the background color,according to the changed background color of the toolbar.
 3. The methodaccording to claim 2, wherein the button color of the toolbar isautomatically changed by using a color-to-grayscale method, wherein thecolor-to-grayscale method comprises: using a formulaGray=R*0.299+G*0.587+B*0.114, wherein Gray is a grayscale value, R is ared color value of the extracted dominant color of the picture, G is agreen color value of the extracted dominant color of the picture, and Bis a blue color value of the extracted dominant color of the picture;and converting the RGB color values of the extracted dominant color ofthe picture to a grayscale value, wherein when the grayscale valueranges from 0 to 0.5, the button color of the toolbar is changed toblack, and when the grayscale value ranges from 0.5 to 1, the buttoncolor of the toolbar is changed to white.
 4. The method according toclaim 1, wherein the extracting a dominant color of a currentlydisplayed picture comprises: a picture obtaining step for obtaining thecurrently displayed picture, wherein the picture comprises multipledisplay units; a color classification step for performing, in a firstcolor space, classification processing on each display unit comprised inthe picture so as to obtain several color categories by classifyingdisplay units having same color characteristics into a same colorcategory, and calculating a quantity of display units corresponding toeach color category; a color-weight calculation step for converting eachcolor category from the first color space to a second color space,obtaining a value of each color category in each dimension of the secondcolor space, determining a weighting function of each dimension of thesecond color space according to a factor that is in a displayrequirement and that corresponds to each dimension of the second colorspace, and calculating a weight of each color category according to thevalue of each color category in each dimension of the second color spaceand the weighting function of each dimension; and a dominant-colorextraction step for calculating color values according to the quantityof display units corresponding to each color category and the weight ofthe color category, and extracting a color category having a highestcolor value to serve as the dominant color of the picture.
 5. The methodaccording to claim 4, wherein the color-weight calculation stepcomprises: converting N color categories obtained after classificationfrom the first color space to the second color space having Mdimensions, to obtain a value of each color category in the second colorspace, wherein a value of an i^(th) color category in a j^(th) dimensionof the second color space is expressed as P_(ij)(i=1, . . . , N; j=1, .. . , M); configuring the weighting function of each dimension of thesecond color space according to the factor that is in the displayrequirement and that corresponds to each dimension of the second colorspace, wherein a weighting function of the j^(th) dimension isF(x_(j))(j=1, . . . , N); and calculating the weight of each colorcategory according to the value and the weighting function of each colorcategory in the second color space, wherein a weight W_(i) of the i^(th)category of color is${W_{i} = {{\sum\limits_{j = 1}^{M}{F\left( P_{ij} \right)}} + C}},$wherein C is a constant except
 0. 6. The method according to claim 4,wherein the weighting function is set so that a dimension with a highercorrelation with a factor in the display requirement, associates with alarger result value calculated by the weighting function of thedimension.
 7. The method according to claim 4, wherein the first colorspace is an RGB space, and the second color space is an HSV space. 8.The method according to claim 7, wherein in the color-weight calculationstep, when a factor corresponding to a saturation rate of the HSV spacein the display requirement is making a displayed color brighter, aweighting function of the saturation rate is set to F(S)=(S/2^(A))²,wherein S is a value of the saturation rate, and A is a positiveinteger.
 9. The method according to claim 7, wherein in the color-weightcalculation step, when a factor corresponding to lightness of the HSVspace in the display requirement is avoiding an extreme colorunfavorable to text display, a weighting function of the lightness isset to: ${F(V)} = \left\{ {\begin{matrix}V & {V < 2^{{p\; 2} - 1}} \\2^{{p\; 2} - 1} & {2^{{p\; 2} - 1} \leq V \leq {2^{{p\; 2} - 2} \times 3}} \\{2^{{p\; 2} + 1} - {2 \times V}} & {V > 2^{{p\; 2} - 1}}\end{matrix},} \right.$ wherein V is a value of the lightness, and avalue of p2 is obtained according to a maximum value 2^(p2)−1 of thevalue V of the lightness of the HSV space.
 10. The method according toclaim 4, wherein the color classification step further comprises:performing, by using the following formula, downsampling on the displayunits comprised in the picture:${\left\lbrack {S_{1}^{\prime},S_{2}^{\prime},{\ldots\mspace{14mu} S_{T}^{\prime}}} \right\rbrack = \left\lbrack {\left\lfloor \frac{S_{1}}{2^{q\; 1}} \right\rfloor,\left\lfloor \frac{S_{2}}{2^{q\; 1}} \right\rfloor,\ldots\mspace{14mu},\left\lfloor \frac{S_{T}}{2^{q\; 1}} \right\rfloor} \right\rbrack},$and classifying display units that are obtained after downsampling andthat have same [S₁′, S₂′, . . . S_(T)′] into a same color category,wherein T is a quantity of dimensions of the first color space, [S₁, . .. , S_(T)] is a value of a single display unit in the first color space,q1 is an integer greater than 0 and less than p, and a value of p isobtained according to a known maximum value 2^(p)−1 of each dimension inthe first color space.
 11. The method according to claim 4, wherein inthe dominant-color extraction step, a color value of each color categoryis obtained by multiplying the quantity of display units correspondingto each color category by the weight.
 12. The method according to claim11, wherein the dominant-color extraction step comprises: extracting anintermediate color value of a color category that has a largest colorvalue to serve as the dominant color of the picture.
 13. The methodaccording to claim 4, wherein before the color classification step, themethod further comprises: a step of scaling down the picture, in orderto reduce side pixels of the picture to a proper value.
 14. The methodaccording to claim 4, further comprising: a step of matching a templateto determine a final dominant color for matching the extracted dominantcolor of the picture with a pre-configured template color, and selectinga template color nearest to the dominant color of the picture as thefinal dominant color of the picture.
 15. An apparatus for changing abackground color of a toolbar with a dominant color of a picture,comprising: a computing device; memory storing instructions, whenexecuted by the computing device, configured to cause the computingdevice to: transparentize a background color of a toolbar of a currentlyrunning application; extract a dominant color of a picture currentlydisplayed on a user interface of the application; display, along withthe picture, the toolbar using a color based on the extracted dominantcolor as the background color of the toolbar on the user interface ofthe application, such that the toolbar and the picture are displayedharmoniously; and when the displayed picture is moved up and down orleft and right with a user operation, keep the background color of thetoolbar unchanged from the color based on the extracted dominant colorwhen the displayed picture is not completely moved out of an operationinterface; and recover the background color of the toolbar to a defaultcolor when the displayed picture is completely moved out of theoperation interface and the operation interface does not have a pictureor a color to display.
 16. The apparatus according to claim 15, whereinthe instructions are further configured to cause the computing device toautomatically change a button color of the toolbar displayed using thecolor based on the extracted dominant color as the background color,according to the changed background color of the toolbar.
 17. Theapparatus according to claim 16, wherein the button color of the toolbaris automatically changed by using a color-to-grayscale method, whereinthe color-to-grayscale method comprises: using a formulaGray=R*0.299+G*0.587+B*0.114, wherein Gray is a grayscale value, R is ared color value of the extracted dominant color of the picture, G is agreen color value of the extracted dominant color of the picture, and Bis a blue color value of the extracted dominant color of the picture;and converting the RGB color values of the extracted dominant color ofthe picture to a grayscale value, wherein when the grayscale valueranges from 0 to 0.5, the button color of the toolbar is changed toblack, and when the grayscale value ranges from 0.5 to 1, the buttoncolor of the toolbar is changed to white.
 18. The apparatus according toclaim 15, wherein the instructions are further configured to cause thecomputing device to recover the background color of the toolbar to adefault color when the displayed picture is completely moved out of anoperation interface and the operation interface does not have a pictureor a color to display.
 19. A computer-based method for changing abackground color of an element bar in accordance with a dominant colorof a picture, comprising: transparentizing, based on an instructionincluded in program code executed by a computing device, a backgroundcolor of an element bar of a currently running application; extracting,based on an instruction included in program code executed by thecomputing device, a dominant color of a picture currently displayed on auser interface of the application; displaying, based on an instructionincluded in program code executed by the computing device, the elementbar using a color based on the extracted dominant color as thebackground color of the element bar, along with the picture on the userinterface of the application, such that the element bar and the pictureare displayed harmoniously; and when the displayed picture is moved upand down or left and right with a user operation, keeping the backgroundcolor of the toolbar unchanged from the color based on the extracteddominant color when the displayed picture is not completely moved out ofan operation interface; and recovering the background color of thetoolbar to a default color when the displayed picture is completelymoved out of the operation interface and the operation interface doesnot have a picture or a color to display.